package com.eastfair.tag.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.core.base.entity.Entity;
import com.eastfair.tag.enumeration.TagResourceTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 *
 * </p>
 *
 * @author zjn
 * @since 2022-03-11
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tg_tag_resource")
@ApiModel(value = "TagResource", description = "")
@AllArgsConstructor
public class TagResource extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @NotNull(message = "请填写项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 资源类型
     */
    @ApiModelProperty(value = "资源类型")
    @Size(max = 255, message = "资源类型长度不能超过255")
    @TableField(value = "resource_type", condition = LIKE)
    @Excel(name = "资源类型")
    private TagResourceTypeEnum resourceType;

    /**
     * 资源id
     */
    @ApiModelProperty(value = "资源id")
    @TableField(value = "resource_id")
    @Excel(name = "资源id")
    private Long resourceId;

    /**
     * 标签id
     */
    @ApiModelProperty(value = "标签id")
    @TableField(value = "tag_id")
    @Excel(name = "标签id")
    private Long tagId;

    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;


    @Builder
    public TagResource(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime,
                       Long projectId, TagResourceTypeEnum resourceType, Long resourceId, Long tagId, Integer isEnabled, Integer isDeleted) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.projectId = projectId;
        this.resourceType = resourceType;
        this.resourceId = resourceId;
        this.tagId = tagId;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
    }

}
